import myaxios from "../MyAxios";

import BASEURL from '@/http/BaseUrl'
const BMDURL = BASEURL.BMDURL

const movieApi = {

  /** 通过ID和类别, 查询电影详情 
   *  @params {Object} params  {id:11}
   *   id: this.$route.params.id,
      type: '电影'
    }
    http://121.37.91.153:3010/query-infosByid?id=2&type=movie
   */
  queryById (params) {
    let url = BMDURL + `/query-infosByid?`
    return myaxios.get(url, params)
  },

  /** 修改电影信息 */
  update (params) {
    let url = BMDURL + "/movie-info/update"
    return myaxios.post(url, params)
  },

  /** 新增电影 */
  add (params) {
    let url = BMDURL + "/admin/yinshi_add"
    return myaxios.post(url, params)
  },

  /**
   * 查询所有的电影类型  
   */
  queryTypes () {
    return myaxios.get(BMDURL + '/movie-types')
  },

  /**
   * 通过页码/每页条目数据  分页查询电影列表
   * @param {Object} params {page:1, pagesize:3}
   */
  queryAll (params) {
    let url = BMDURL + "/movie-infos"
    return myaxios.get(url, params)
  },

  /**
   * 模糊查询电影列表
   * @param {Object} params {name, page, pagesize}
   * /query-infosByname?name=测&page=1&pagesize=10
   */
  queryAllByName (params) {
    let url = BMDURL + `/query-infosByname?name=${params.name}&page=${params.page}&pagesize=${params.pagesize}`
    return myaxios.post(url, params)
  },

  /**
   * 删除电影
   * @param {Object} params  {id}
   */
  delete (params) {
    let url = BMDURL + '/movie-info/del'
    return myaxios.post(url, params)
  }
}

export default movieApi;